/* 
    登录及用户权限相关API
*/
import http from "@/util/http"
import store from "../store/index"

/* 登录 */
export function loginIn(userData) {
    return http.post("/user/login", {
        account: userData.id,
        password: userData.psd
    })
}

/* 获取用户权限 */
export function permission() {
    let role = store.state.UserRole || localStorage.getItem("role");
    switch (role) {
        case "管理人员":
            return http.get("/routing/admin");
        case "工程专工":
            return http.get("/routing/engineering");
        case "物资专工":
            return http.get("/routing/supplies");
        case "物资部长":
            return http.get("/routing/treasury");
        case "作业小组组长":
            return http.get("/routing/workGroup");
        case "作业队技术员":
            return http.get("/routing/workTeam");
        default:
            return null;
    }
}

/* 传说中的checkName */
export function checkName(account) {
    return http.post("/user/check", {
        account: account
    })
}
